package com.cwd.yg.service.impl;

import com.cwd.yg.dao.TimeDao;
import com.cwd.yg.pojo.TimeTable;
import com.cwd.yg.service.TimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @Description：TimeServiceImpl
 * @Author ：Cwd
 * @Date ：2022/2/6 23:31
 */
@Service
public class TimeServiceImpl implements TimeService {

    @Autowired
    private TimeDao timeDao;

    @Override
    public List<TimeTable> queryAllTimes() {
        List<TimeTable> timeTables = Optional
                .ofNullable(timeDao.queryAllTimes())
                .orElse(Collections.emptyList());
        return timeTables.stream()
                .collect(Collectors.toList());
    }
}
